<template>
  <view>
    <u-form :model="form" ref="uForm">
      <u-form-item label="收件人" label-width='100' prop="addressee">
        <u-input v-model="form.addressee" />
      </u-form-item>
      <u-form-item label="标题" prop="sendtitle">
        <u-input v-model="form.sendtitle" />
      </u-form-item>
     <!-- <u-form-item label="内容" prop="sendtxt">
        <u-input v-model="form.sendtxt" />
      </u-form-item> -->
	  <RichText @getDditorData='getDditorData' ref="refRichText"></RichText>
    </u-form>
	 <!-- <editor id="editor" class="ql-container" @ready="onEditorReady"></editor> -->
	<corresponding v-if='corresponding'></corresponding>

  </view>
</template>

<script>
export default {
  data() {
    return {
      form: {
        addressee: "1239184745@qq.com",
        sendtitle: "",
        sendtxt: "",
        sendhtml: "",
      },
	  corresponding:false,
      rules: {
        emali: [
          {
            required: true,
            message: "请输入收件人",
            // 可以单个或者同时写两个触发验证方式
            trigger: ["change", "blur"],
          },
        ],
        sendtitle: [
          {
            required: true,
            min: 5,
            message: "标题不能少于5个字",
            trigger: "change",
          },
        ],
        sendtxt: [
          {
            required: true,
            min: 5,
            message: "内容不能少于5个字",
            trigger: "change",
          },
        ],
		
      },
    };
  },
  mounted() {},
  methods: {
	  onEditorReady() {
	  		uni.createSelectorQuery().select('#editor').context((res) => {
				console.log(res);
	  			this.editorCtx = res.context
	  		}).exec()
	  	},
		async getDditorData(dataMali){
			this.corresponding = true;
			this.form.sendhtml = dataMali.html;
			const data = await this.http(this.api.setMail, { ...this.form });
			this.corresponding = false;
			if (data) {
			  uni.showToast({
			    title: "发送邮件成功",
			    icon: "none",
			  });
			  this.$refs.refRichText.clear();
			} 
			
		},

    },

};
</script>
